<template>
  <div class="mr-sr-midSearch">
    <div class="mr-sr-midSearhchBox">
      <ul>
        <li>
          <span>零件图号</span>
        </li>
        <li>
          <el-input
            size="mini"
            v-model="searchData.tuhao"
            placeholder="请输入内容"
             
          ></el-input>
        </li>
        <li>
          <span>质量编号</span>
        </li>
        <li>
          <el-input
            size="mini"
            v-model="searchData.qualityNumber"
            placeholder="请输入内容"
             
          ></el-input>
        </li>
        <li>
          <span>移交人</span>
        </li>
        <li>
          <el-input
            size="mini"
            v-model="searchData.person"
            placeholder="请输入内容"
             
          ></el-input>
        </li>
        <li>
          <span>移交时间</span>
        </li>
        <li>
          <el-date-picker
            size="mini"
            v-model="searchData.startTime"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          ></el-date-picker>
        </li>
        <li>
          <span>到</span>
        </li>
        <li>
          <el-date-picker
            size="mini"
            v-model="searchData.endTime"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
            default-time="12:00:00"
          ></el-date-picker>
        </li>
        <li>
          <el-button
            size="mini"
            type="primary"
            @click="scanningSearch"
            style="margin-left: 5px"
            >查询</el-button
          >
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import { scanSearch } from '@/utils/api.js'
export default {
  name: "MrSrMidSearch",
  data() {
    return {
      searchData: {
        startTime: "",
        endTime: "",
        tuhao: "",
        qualityNumber: "",
        person: "",
      },
      pageSize:20,
      pageNumber:1
    };
  },
  mounted() {
    this.getNowTime();
    // 接收Tables传的pageSize
    this.$bus.$on('srPageNumbers',(e)=>{
      this.pageSize = e
    })
  },
  methods: {
    getNowTime() {
      var now = new Date();
      var year = now.getFullYear(); //得到年份
      var month = now.getMonth(); //得到月份
      var date = now.getDate(); //得到日期
      month = month + 1;
      month = month.toString().padStart(2, "0");
      var date2 = date + 1;
      date = date.toString().padStart(2, "0");
      date2 = date2.toString().padStart(2, "0");
      var defaultDate1 = `${year}-${month}-${date}`;
      var defaultDate2 = `${year}-${month}-${date2}`;
      this.$set(this.searchData, "startTime", defaultDate1);
      this.$set(this.searchData, "endTime", defaultDate2);
    },
    scanningSearch() {
      scanSearch({
        funcType:"return",
        pageParameter:{
          rows:this.pageSize,
          page:this.pageNumber
        },
        searchParams:{
          receiveEmpCode:this.searchData.person,
		      qualityCode:this.searchData.qualityNumber
        },
        drawNo:this.searchData.tuhao,
        startTime:this.searchData.startTime,
        endTime:this.searchData.endTime,
      }).then((res)=>{
        console.log("扫码退回条件查询",res);
        // 将得到的表格数据给表格更新数据，以及将查询条件的值给分页进行分页操作
        this.$bus.$emit('scanReturnSearchData',{
          resData:res.data.responseBody.result,
          receiveEmpCode:this.searchData.person,
          qualityCode:this.searchData.qualityNumber,
          drawNo:this.searchData.tuhao,
          startTime:this.searchData.startTime,
          endTime:this.searchData.endTime
        })
      })
      
    },
  },
};
</script>
<style scoped>
.mr-sr-midSearch {
  overflow: hidden;
  /* border-left: 1px solid rgb(204, 204, 204);
  border-right: 1px solid rgb(204, 204, 204);
  border-bottom: 1px solid rgb(204, 204, 204); */
  font-size: 14px;
}
.mr-sr-midSearhchTitle {
  padding: 5px 2px;
  background-color: rgb(57, 135, 199);
  color: white;
}
.mr-sr-midSearhchBox {
  padding: 5px 2px;
}
.mr-sr-midSearhchBox ul li {
  height: 35px;
  float: left;
  margin-right: 10px;
  line-height: 35px;
}
.mr-sr-midSearhchBox ul li .el-input {
  width: 175px;
}
</style>